package com.atguigu.singleton.type8;


public class SingletonTest08 {
	public static void main(String[] args) {
		//测试
		Singleton instance = Singleton.INSTANCE;
		Singleton instance2 = Singleton.INSTANCE;
		System.out.println(instance==instance2);//true
		System.out.println("instance.hashCode="+instance.hashCode());
		System.out.println("instance2.hashCode="+instance2.hashCode());
	}
}

//枚举实现单例，推荐使用
enum Singleton{
	INSTANCE;
	public void sayOk() {
		System.out.println("ok!~");
	}
}